<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<%@ page import="com.ce.pms.exception.*"%>
<%@ page import="org.springframework.dao.DeadlockLoserDataAccessException"%>


<%
			if (request
			.getAttribute(com.ce.pms.exception.support.StrutsExceptionHandler.WEBX_THE_EXCEPTION_KEY) == null)
		return;
%>
<%
			com.ce.pms.exception.support.ExceptionWrapper wrapper = (com.ce.pms.exception.support.ExceptionWrapper) request
			.getAttribute(com.ce.pms.exception.support.StrutsExceptionHandler.WEBX_THE_EXCEPTION_KEY);
%>

<script>


<%

	String url = "";
  session.setAttribute("messageSession",request.getAttribute("exceptionMessage"));
	if(wrapper.getCause() instanceof BusinessException){
		BusinessException be = (BusinessException)wrapper.getCause();

		if(wrapper.getMessage() != null){
			if(BusinessException.WARNING.equals(be.getType())){
				url = path+"/common_commonAction.do?method=forwardException&exceptionType=warning";
			}else if(BusinessException.ERROR.equals(be.getType())){
				url = path+"/common_commonAction.do?method=forwardException&exceptionType=failure";
			}else{
				url = path+"/common_commonAction.do?method=forwardException&exceptionType=error";
			}

		}
	}else if(wrapper.getCause() instanceof DataAccessException){

		if(wrapper.getMessage() != null){
			url = path+"/common_commonAction.do?method=forwardException&exceptionType=error";
		}
	}else if(wrapper.getCause() instanceof UILayerException){
		UILayerException bee = (UILayerException)wrapper.getCause();
		if(wrapper.getMessage() != null){
			if(UILayerException.WARNING.equals(bee.getType())){
				url = path+"/common_commonAction.do?method=forwardException&exceptionType=warning";
			}else if(UILayerException.ERROR.equals(bee.getType())){
				url = path+"/common_commonAction.do?method=forwardException&exceptionType=failure";
			}else{
				url = path+"/common_commonAction.do?method=forwardException&exceptionType=error";
			}
		}
	}else if(wrapper.getCause() instanceof DeadlockLoserDataAccessException){
		url = path+"/common_commonAction.do?method=forwardException&exceptionType=error&message=common:deadlockLoserDataAccessException";
	}else{

		url = path+"/common_commonAction.do?method=forwardException&exceptionType=error&message=common:unknown_exception";
	}



%>

top.windowOpen('<%=url%>', "exception", '', 165, 380, true, "exceptionIfr");

      if(this.windowClose){
		 windowClose();
	  }else{
	     top.windowClose();
	  }

	  if (typeof(window.parent.closeExceptionPage)=="function"){
                 parent.closeExceptionPage();
      }

</script>

